package sk.project.accounting.data.services;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sk.project.accounting.data.dao.UserDao;
import sk.project.accounting.data.model.Company;
import sk.project.accounting.data.model.User;

@Service
public class UserServiceImpl implements UserService{

	private static Logger log = Logger.getLogger(UserServiceImpl.class);
	
	@Autowired
	private UserDao userDao;
	
	@Transactional
	@Override
	public List<User> getAllUsers() {
		List<User> users = userDao.getAllUsers();
		return users;
	}

	@Transactional
	@Override
	public User getUserById(int id) {
		return userDao.getUserById(id);
	}

	@Transactional
	@Override
	public int insertUser(User user) {		
		return userDao.insertUser(user);
	}

	@Transactional
	@Override
	public void deleteUser(User user) {
		userDao.deleteUser(user);
	}

	@Override
	public void deleteUserById(int id) {
		User user = userDao.getUserById(id);
		userDao.deleteUser(user);
	}

}
